<template>
	<view class="homepage">
		<view class="toptab">
			<view class="topleft">
				<view class="itemtab" :class="tab==1?'act':''" @click="selecttab(1)">
					用户
				<view class="line"></view>
				</view>
				<view class="itemtab" :class="tab==2?'act':''" @click="selecttab(2)">
					医生
				<view class="line"></view>
				</view>
			</view>
			<view class="topright" v-if="tab==1" @click="winshow=true">
				筛选
			</view>
			<view class="topright" v-if="tab==2" @click="winshow2=true">
				筛选
			</view>
		</view>
		
		<!-- //用户列表 -->
		<view class="list" v-if="tab==1">
			<view class="itemlist" v-for="item in list" :key="item.id">
				<view class="user" >
					<view class="userleft">
						<view class="lefttop">
							<view class="name">
								{{item.memberName}}
							</view>
							推荐人:
							<view class="name">
								{{item.recommenderName||''}}
							</view>
						</view>
						<view class="lefttop">
						手机号：{{item.memberPhone}}
						</view>
						<view class="lefttime">
							{{item.createTime}}
						</view>
					</view>
					<view class="userlever">
						{{item.memberLevel==3?'专病会员':item.memberLevel==4?'银卡会员':item.memberLevel==5?'金卡会员':item.memberLevel==6?'黑卡会员':''}}
					</view>
				</view>
			</view>
		</view>
		
		<!-- 医生列表 -->
		<view class="list" v-if="tab==2">
			<view class="itemlist" v-for="item in list1" :key="item.id">
				<view class="doctor"  >
					<view class="docleft">
						<view class="doctop">
							<view class="name">
								{{item.dname}}
							</view>
							推荐人:
							<view class="name">
								{{item.recommenderName||''}}
							</view>
						</view>
						<view class="doctop">
						{{item.phone}}
						</view>
						
						<view class="doctime">
							{{item.createTime}}
						</view>
					</view>
					<view class="docright">
						<view class="jgname">
							{{item.jigouName}}
						</view>
						<view class="jgname">
							{{item.keshi}}
						</view>
					</view>
					
				</view>
			</view>
		</view>
		
		
		
		
		
		<view class="pagewin" v-if="winshow">
			<view class="win">
				<view class="iconfont icon-guanbi" @click="winshow=false"></view>
				<view class="wintitle">
					选择项目服务
				</view>
				<view class="line">
					<radio-group class="labelgroup" @change="radioChange">
									<label class="labelbox" >
										<view>
											<radio value="" />
										</view>
										<view>全部</view>
									</label>
									<label class="labelbox" >
										<view>
											<radio value="0"  />
										</view>
										<view>专病</view>
									</label>
									<label class="labelbox" >
										<view>
											<radio value="1"  />
										</view>
										<view>会员</view>
									</label>
						</radio-group>
				</view>
				<view class="wintitle">
					选择时间
				</view>
				<view class="line">
					<picker mode="date" :value="date" start="2025-11-01" end="2055-12-30" @change="selectstarttime">
						<view class="picker">{{starttime}}</view>
					</picker>
					至
					<picker mode="date" :value="date" start="2025-11-01" end="2055-12-30" @change="selectendtime">
						<view class="picker">{{endtime}}</view>
					</picker>
				</view>
				<view class="winbtn" @click="search">
					确定
				</view>
			</view>
		</view>
		
		
		
		
		<view class="pagewin" v-if="winshow2">
			<view class="win">
				<view class="iconfont icon-guanbi" @click="winshow2=false"></view>
				<view class="wintitle">
					输入医生姓名
				</view>
				<view class="line">
			      <input type="text" v-model="name"  placeholder="请输入姓名" />
				</view>
				<view class="wintitle">
					选择时间
				</view>
				<view class="line">
					<picker mode="date" :value="date" start="2025-11-01" end="2055-12-30" @change="selectstarttime1">
						<view class="picker">{{starttime1}}</view>
					</picker>
					至
					<picker mode="date" :value="date" start="2025-11-01" end="2055-12-30" @change="selectendtime1">
						<view class="picker">{{endtime1}}</view>
					</picker>
				</view>
				<view class="winbtn" @click="searchdoctor">
					确定
				</view>
			</view>
		</view>
		
		
		
		
		
		
		
		
		
		<view class="foot-tabbar" >
			<view class="itemfootbar" @click="goxueshu">
				<image src="/static/tabbar/学位帽.png" mode=""></image>
				<view class="tabbarname ">
					学术
				</view>
			</view>
			<view class="itemfootbar" >
				<image src="/static/tabbar/首页 (3).png" mode=""></image>
				<view class="tabbarname  footact">
					用户
				</view>
			</view>
		
		
			<view class="itemfootbar" @click="gomember" >
				<image src="/static/tabbar/团队.png" mode=""></image>
				<view class="tabbarname ">
				成员
				</view>
			</view>
			<view class="itemfootbar" @click="gocenter" >
				<image src="/static/tabbar/我的.png" mode=""></image>
				<view class="tabbarname ">
					我的
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import { getTuijianDailiList,getTuijianMemberDailiList} from '../../utils/daili.js'
	export default {
		data() {
			return {
				winshow:false,
				winshow2:false,
				tab:1,
				list:[],
				list1:[],
				current:'',
				indes:'',
				starttime:'',
				endtime:'',
				starttime1:'',
				endtime1:'',
				name:''
			}
		},
	onShow() {
		let p={
			phone:uni.getStorageSync('phone'),
			type:'',
			name:'',
			startTime:'',
			endTime:''
		}
		getTuijianMemberDailiList(p).then(res=>{
			console.log(res,'用户列表')
			this.list=res.data.data
		})
		let a={
			phone:uni.getStorageSync('phone'),
			name:'',
			startTime:'',
			endTime:''
		}
		getTuijianDailiList(a).then(res=>{
			console.log(res,'医生列表')
			this.list1=res.data.data
		})
	},
		methods: {
			selecttab(e){
				this.tab=e
				
			},
			
			
			selectstarttime1(e){
				
				this.starttime1=e.detail.value
				
			},
			selectendtime1(e){
				this.endtime1=e.detail.value
			},
			selectstarttime(e){
				this.starttime=e.detail.value
				
			},
			selectendtime(e){
				this.endtime=e.detail.value
			},
			radioChange(e){
				
				this.current=e.detail.value
			},
			search(){
				if(this.starttime&&this.endtime){
					if(new Date(this.starttime) > new Date(this.endtime)){
						uni.showToast({
							title: '开始时间不能大于结束时间',
							icon:'none',
							duration: 2000
						});

						return
					}
				}
				let p={
					type:this.current,
					phone:uni.getStorageSync('phone'),
					name:'',
					startTime:this.starttime,
					endTime:this.endtime
				}
				getTuijianMemberDailiList(p).then(res=>{
					console.log(res)
					if(res.data.code==200){
						this.winshow=false
						this.list=res.data.data
					}
				})
			},
			searchdoctor(){
				if(this.starttime1&&this.endtime1){
					if(new Date(this.starttime1) > new Date(this.endtime1)){
						uni.showToast({
							title: '开始时间不能大于结束时间',
							icon:'none',
							duration: 2000
						});
				
						return
					}
				}
				let p={
					
					phone:uni.getStorageSync('phone'),
					name:this.name,
					startTime:this.starttime1,
					endTime:this.endtime1
				}
				getTuijianDailiList(p).then(res=>{
					console.log(res)
					if(res.data.code==200){
						this.winshow2=false
						this.list1=res.data.data
					}
				})
			},
			
			
			
			
			goxueshu(){
				uni.redirectTo({
					url:'/pages/newxueshu/newxueshu'
				})
			},
			gomember(){
				uni.redirectTo({
					url:'/pages/newteam/newteam'
				})
			},
			gocenter(){
				uni.redirectTo({
					url:'/pages/newcenter/newcenter'
				})
			},
		}
	}
</script>

<style lang="less" scoped>
  .homepage{
	  width: 750rpx;
	   box-sizing: border-box;
	   padding-bottom: 200rpx;
	  .toptab{
		  width: 100%;
		  display: flex;
		  align-items: center;
		  height: 80rpx;
		  margin-top: 20rpx;
		  justify-content: space-between;
		  box-sizing: border-box;
		  padding: 20rpx;
		  .topleft{
			  width: 50%;
			  display: flex;
			  height: 80rpx;
			  align-items: center;
			  justify-content: space-evenly;
			  .itemtab{
			  	width: 50%;
					  text-align: center;
					  font-size: 30rpx;
					  font-weight: bold;
					  color: gray;
					  .line{
						  width: 50rpx;
						  height: 6rpx;
						  border-radius: 3rpx;
						  margin: 6rpx auto;
					  }
			  }
			  .act{
				  color: #1a4f8a;
				  .line{
					  background-color: #1a4f8a;
				  }
			  }
		  }
		  .topright{
			  font-size: 30rpx;
			  font-weight: bold;
			  margin-top: -10rpx;
		  }
		  
	  }
	  .list{
		  width: 94%;
		  box-sizing: border-box;
		  margin: auto;
		 background-color: white;
		 .itemlist{
			 width: 100%;
			 box-sizing: border-box;
			 padding: 20rpx;
			 margin-bottom: 20rpx;
			 .user{
				 width: 100%;
				 display: flex;
				 align-items: center;
				 justify-content: space-between;
				 .userleft{
					 width: 60%;
					 .lefttop{
						 display: flex;
						 align-items: center;
						 font-size: 30rpx;
						 line-height: 2;
						 .name{
							 margin-right: 20rpx;
							 font-weight: bold;
						 }
					 }
					 .lefttime{
						 font-size: 28rpx;
						 font-weight: bold;
					 }
				 }
				 .userlever{
					 background-color: #F5FCFF;
					 font-size: 28rpx;
					 font-weight: bold;
					 color: #1a4f8a;
					 padding: 6rpx 8rpx;
				 }
				 
			 }
			 .doctor{
				width: 100%;
				display: flex;
				align-items: center; 
				justify-content: space-between;
				.docleft{
					width: 45%;
					.doctop{
						display: flex;
						align-items: center;
						font-size: 28rpx;
						font-weight: bold;
						line-height: 2;
						.name{
							font-size: 30rpx;
							margin-right: 14rpx;
						}
					}
					.doctime{
						font-size: 28rpx;
						font-weight: bold;
					}
				}
				.jgname{
					font-size: 28rpx;
					background-color: #F4F4F4;
					color: #1a4f8a;
					padding: 6rpx 10rpx;
					margin-top: 10rpx;
					text-align: center;
				}
			 }
		 }
		  
	  }
	  .pagewin{
		 width: 100vw;
		  height: 100vh;
		  background-color: rgba(0, 0, 0, 0.5);
		  position: fixed;
		  top: 0;
		  right: 0;
		  bottom: 0;
		  left: 0;
		  .win{
			  position: absolute;
			  top: 35vh;
			  left: 0;
			  right: 0;
			  bottom: 0;
			  border-top-right-radius: 20rpx;
			  border-top-left-radius: 20rpx;
			  background-color: white;
               box-sizing: border-box;
			   padding: 40rpx 20rpx;
			   .iconfont{
				   position: absolute;
				   right: 20rpx;
				   top: 20rpx;
				   
			   }
			   .wintitle{
				   font-size: 30rpx;
				   font-weight: bold;
				   margin: 80rpx 20rpx;
			   }
			   .line{
				   width: 100%;
				   display: flex;
				   margin: 30rpx 0;
				   align-items: center;
				   justify-content: space-evenly;
				   input{
					    background-color: #F0F0F0;
				   }
				   .labelgroup{
					   width: 100%;
					   display: flex;
					   align-items: center;
					   justify-content: space-evenly;
					   .labelbox{
						   display: flex;
						   align-items: center;
						   font-size: 30rpx;
						   font-weight: bold;
					   }
				   }
				   
				   .picker{
					   width: 300rpx;
					   height: 60rpx;
					   background-color: #F0F0F0;
					   text-align: center;
					   font-size: 28rpx;
					   line-height: 60rpx;
				   }
			   }
			   .winbtn{
				   width: 80%;
				   height: 70rpx;
				   color: white;
				   background-color: #1a4f8a;
				   text-align: center;
				   line-height: 70rpx;
				   border-radius: 35rpx;
				   margin: 70rpx auto;
			   }
		  }
		  
	  }
	  
	  
	  
	  
	  
	  
	  .foot-tabbar{
	  	width: 100%;
	  	height: 150rpx;
	  	position: fixed;
	  	left: 0;
	  	right: 0;
	  	bottom: 0;
	  	display: flex;
	  	align-items: center;
	  	justify-content: space-evenly;
	  	background: white;
	  	overflow: visible;  /* 允许溢出 */
	  	
	  	.itemfootbar{
	  		width: 20%;
	  		height: 100%;
	  		text-align: center;
	  		image{
	  			width: 60rpx;
	  			height: 60rpx;
	  			margin: auto;
	  		}
	  		.tabbarname{
	  			font-size: 26rpx;
	  			color: #969696;
	  			font-weight: bold;
	  		}
	  		.footact{
	  			color: #1a4f8a;
	  		}
	  		
	  	}
	
	  }
  }
</style>
